This course will including programming in a language called python. No prior experience with python is necessary.
All of the work you do in python will be in an electronic notebook like this one. It can contain both regular text and computer code.
Each week you will turn in a notebook like this containing your computer code and your discussion of the code.
At the top of this notebook it says "IP[y] Notebook"; next to that is the name of the notebook, "Lab 1". Click on "Lab 1" and rename the notebook. The new name should include the words "Lab 1" and your name (assuming you want credit for the lab).
You can edit the text in any section of a notebook by:
Enter key while holding down Shift) You edit this cell... double click on it, edit, then Shift-Enter when you are done editing.
(You may have noticed you can do basic formatting like making text bold...feel free to ignore that for now).
Computer code in an ipython notebook looks different thatn normal text. It is in a gray block with special prompts, like In[ ].
You run a code cell the same way you make a text cell look nice: Push Shift-Enter.
Click on the cell below and push Shift-Enter.
In [ ]:
print "Hello stranger!"
Editing code is just like editing text:
Edit the code in the cell above so that it prints Hello physicist! when you run it (or put you name in in place of stranger).
There are no real emergencies in a notebook, of course...but there will be times when things don't work as exepcted.
Sometimes that happens because there is an error in your code. Sometimes it happens because notebook cells are run out of order. Sometimes there is a problem behind the scenes with how python is operating.
To see an example of what an error message looks like in a notebook, execute the code cell below; no need to fix the error, the point is simply to see what one looks like.
In [ ]:
print "Goodbye for now
Errors like this are almost always mistakes in the code in the cell you are running, but can sometimes occur for more compicated reasons.
Three things:
At times like this it is helpful to remind yourself of something I read once in a programming book:
While learning something new, many students will think, “Damn, this is hard for me. I wonder if I am stupid...” Before going any farther, assure yourself that you are not stupid and that some things are hard. Armed with this silly affirmation and a well-rested mind, you are ready to [learn anything].
Aaron Hillegass, Cocoa Programming for Mac OSX, 3rd Ed.